/*
 * Copyright (c) 2002-2004, Inversoft, All Rights Reserved
 *
 * This software is distribuable under the GNU Lesser General Public License.
 * For more information visit gnu.org.
 */
package org.emergent.antbite.savant;


import java.io.File;


/**
 * <p>
 * This class is a workflow process that attempts to download
 * artifacts from the internet using the maven scheme via HTTP.
 * </p>
 *
 * <p>
 * Maven's URL scheme is
 * <b>domain</b>/<b>project</b>/jars/<b>name</b>-<b>version</b>.jar
 * </p>
 *
 * <p>
 * In order to determine the domain in the URL, either a
 * properties file can be read for group/domain pairs. Or
 * a standard location can be setup in this class.
 * </p>
 *
 * @author  Brian Pontarelli
 */
public class MavenInternetProcess extends InternetProcess {

    private static final URLBuilder builder = new MavenURLBuilder();


    /**
     * <p>
     * Maven does not support artifact dependencies so this method is a no-op and
     * always returns false.
     * </p>
     */
    public boolean resolveArtifactDependencies(Artifact artifact,
            LocalCacheStore localCache)
    throws SavantException {
        return false;
    }

    /**
     * Using a simple URL connection, this grabs the date of the URL resource and
     * then attempts to store the stream from the URL to the local cache.
     *
     * @param   artifact The artifact to store
     * @param   localCache The local cache to store the artifact in
     * @return  The File if downloaded and stored
     */
    public File fetch(Artifact artifact, LocalCacheStore localCache)
    throws SavantException {
        return findFile(builder, artifact, localCache);
    }


    /**
     * Returns MavenProcess.
     */
    public String getProcessName() {
        return "MavenProcess";
    }
}